package top.appx.easysql;

import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * Created by john on 2015/10/16.
 */
public class Restrain{
    private String key;
    private Object[] values;
    private RestrainType restrainType;

    private Restrain(String key, Object[] values, RestrainType restrainType) {
        this.key = key;
        this.values = values;
        this.restrainType = restrainType;
    }

    public static Restrain page(int page,int pageSize){
        return new Restrain(null,new Object[]{page,pageSize},RestrainType.page);
    }
    public static Restrain max(int num){
        return new Restrain(null,new Object[]{num},RestrainType.max);
    }
    public static Restrain start(int num){
        return new Restrain(null,new Object[]{num},RestrainType.start);
    }
    public static Restrain between(String key,Object lo,Object hi){
        return new Restrain(key,new Object[]{lo,hi},RestrainType.between);
    }
    public static Restrain eq(String key,Object value){
        return new Restrain(key,new Object[]{value},RestrainType.eq);
    }
    public static Restrain lt(String key,Object value){
        return new Restrain(key,new Object[]{value},RestrainType.lt);
    }
    public static Restrain gt(String key,Object value){
        return new Restrain(key,new Object[]{value},RestrainType.gt);
    }
    public static Restrain like(String key,String value){return new Restrain(key,new Object[]{value},RestrainType.like);}


    public static Restrain add(String key,Object... objects){return new Restrain(key,objects,RestrainType.add);}

    public static Restrain in(String key, Object[] values){
        return new Restrain(key,values,RestrainType.in);
    }
    public static  Restrain notin(String key,Object[] values){
        return new Restrain(key,values,RestrainType.notin);
    }


    public static Restrain order(String key){
        return new Restrain(key,null,RestrainType.order);
    }
    public static Restrain orderDesc(String key){
        return new Restrain(key,null,RestrainType.orderDesc);
    }
    public RestrainType getRestrainType() {
        return restrainType;
    }

    public String getKey() {
        return key;
    }

    public Object[] getValues() {
        return values;
    }

}
